@extends('admin::layouts.master')
<style>
    table{

        table-layout:fixed;/* 只有定义了表格的布局算法为fixed，下面td的定义才能起作用。 */
    }
    td{
        width: 90%;
        word-break:keep-all;/* 不换行 */
        white-space:nowrap;/* 不换行 */
        overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */
        text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/
    }
</style>
@section('content')
    <div class="card" id="app">
        <div class="card-header">留言管理</div>
        <div class="tab-container">
            <ul role="tablist" class="nav nav-tabs" >
                <li class="nav-item"><a href="/shop/article" class="nav-link active">留言列表</a></li>
            </ul>
            <div class="card card-contrast card-border-color-success">
                <div class="card-body">
                    <table class="table">
                        <thead>
                        <tr>
                            <th style="width: 10%;">编号</th>
                            <th>昵称</th>
                            <th>留言内容</th>
                            <th>留言时间</th>
                            <th>&nbsp;&nbsp;&nbsp;&nbsp;</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($data as $d)
                            <tr>
                                <td>{!! $d['id'] !!}</td>
                                <td>{!! $d->user->name !!}</td>
                                <td>{!! $d['content'] !!}</td>
                                <td>{!! $d['created_at']->diffForHumans() !!}</td>
                                <td class="text-right">
                                    @if($d['status']==0)
                                        <a href="{{route('updates',$d['id'])}}" class="btn btn-secondary">未通过</a>
                                    @else
                                        <a href="{{route('todel',$d['id'])}}" class="btn btn-success">已通过</a>
                                    @endif
                                    <button type="button" class="btn btn-secondary btn-danger" onclick="del({{$d['id']}},this)">删除</button>
                                    <form action="{{route('comment.destroy',$d['id'])}}" hidden method="post">
                                        @csrf @method('DELETE')
                                    </form>
                                </td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="float-right">
        {!!  $data->links() !!}
    </div>
@endsection
@section('script')
    <script>
        function del(id, el) {
            if (confirm('确定删除吗？')) {
                $(el).next('form').trigger('submit')
            }
        }
    </script>
@endsection
